<?php
$phone	= $_POST['searchstring'];
$view	= $_POST['searchtype'];
$techno	= $_POST['searchtechno'];

if(trim($techno)=="4G"){
	include_once("Vendors/HSS_Online/Classes/Request.php");
	include_once("Vendors/HSS_Online/Classes/Request_HSS.php");
	include_once("Vendors/HSS_Online/Classes/Parse_HSS.php");
	include_once("Vendors/HSS_Online/Classes/Translate_HSS.php");
	$ask	= new Request();
	$res	= $ask->Request_MSISDN($phone);
	if($res['trans']['MSISDN']==""){
		echo "<center>MSIDN no disponible en 4G</center>";
		exit;
	}
}else{
	include_once("Vendors/HLR_Online/Classes/Request.php");
	include_once("Vendors/HLR_Online/Classes/Request_HLR.php");
	$ask	= new Request();
	$res	= $ask->Request_MSISDN($phone,$view);
	if(($res['SUSCRIBER_IDENTITY']['MSISDN']=="")AND($view=="html")){
		echo "<center>MSIDN no disponible en 2G-3G</center>";
		exit;
	}
}
switch($view){
	case "xml":
		echo "<b>Comando SUB:</b><br><pre>";
		print htmlentities($res['orig']['SUB']);
		echo "</pre><b>Comando DYNSUB:</b><br><pre>";
		print htmlentities($res['orig']['DYNSUB']);
		echo "</pre><b>Comando CFALL:</b><br><pre>";
		print htmlentities($res['orig']['CFALL']);
		echo "</pre><b>Comando ECATEGORY:</b><br><pre>";
		print htmlentities($res['orig']['ECATEGORY']);
		echo "</pre><b>Comando CWAIT:</b><br><pre>";
		print htmlentities($res['orig']['CWAIT']);
		echo "</pre><b>Comando OPTGPRS:</b><br><pre>";
		print htmlentities($res['orig']['OPTGPRS']);
		echo "</pre>";
	break;

// Inicio perfil Tecnico

	case "array":
		if($techno=="4G"){
			


			echo "<pre>";
			echo var_dump($res);
			echo "</pre>";
		


		}else{
			foreach($res AS $line){

				echo $line."<br>"."\r\n";
			}
		}
	break;
	
// Fin Perfil Tecnico

// Genera perfil COMERCIAL

	case "html":
		if(trim($techno)=="4G"){
		?>
		<table border=1 width=100%>
			<tr>
				<td colspan=6 bgcolor="#CCCCCC">
					&nbsp;<b><?php echo $this->mainObj->translateWord('SUBS_INFO_TITLE');?></b>
				</td>
			</tr>
			<tr>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('HLR');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('MSISDN');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('IMSI');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('STATUS');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('AUTH');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('SERVICES');?></b>
				</td>
			</tr>
			<tr>
				<td align=center>
					<?php echo $res['trans']['HLR'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['MSISDN'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['IMSI'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['STATUS'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['AUTH'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['SERVICES'];?>
				</td>
			</tr>
			<tr>
				<td colspan=6>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan=6 bgcolor="#CCCCCC">
					&nbsp;<b><?php echo $this->mainObj->translateWord('LOC_INFO_TITLE');?></b>
				</td>
			</tr>
			<tr>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('VOICEREGS');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('MSC');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('DATAREGS');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('COUNTRY');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('OPERATOR');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('CENTRAL');?></b>
				</td>
			</tr>
			<tr>
				<td align=center>
					<?php echo $res['trans']['VOICEREGS'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['MSC'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['DATAREGS'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['COUNTRY'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['OPERATOR'];?>
				</td>
				<td align=center>
					<?php echo $res['trans']['CENTRAL'];?>
				</td>
			</tr>
			<tr>
				<td colspan=6 bgcolor="#EFEFEF">
					&nbsp;<b><?php echo $this->mainObj->translateWord('DATA4GREGS');?></b>
				</td>
			</tr>
			<tr>
				<td colspan=6>
					&nbsp;<?php echo $res['trans']['DATA4GREGS'];?>
				</td>
			</tr>
			<tr>
				<td colspan=6>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan=6 bgcolor="#CCCCCC">
					&nbsp;<b><?php echo $this->mainObj->translateWord('SER_INFO_TITLE');?></b>
				</td>
			</tr>
			<tr>
				<td align=center bgcolor="#CCCCCC" colspan=4>
					<b><?php echo $this->mainObj->translateWord('SER_INFO_SUBTITLE');?></b>
				</td>
				<td align=center bgcolor="#CCCCCC" colspan=2>
					<b><?php echo $this->mainObj->translateWord('EST_INFO_SUBTITLE');?></b>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('SMSENABLED');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['SMSENABLED'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('SMSORIGIN');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['SMSORIGIN'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('ROAM_TRAF_REST');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['ROAM_TRAF_REST'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('INTER_TRAF_REST');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['INTER_TRAF_REST'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('TRAFIC_ENABLE');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['TRAFIC_ENABLE'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('VOICEMAIL_ALL');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['VOICEMAIL_ALL'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('VOICEMAIL_BUSY');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['VOICEMAIL_BUSY'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('VOICEMAIL_NOHANG');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['VOICEMAIL_NOHANG'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('VOICEMAIL_OUT');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['VOICEMAIL_OUT'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('SUSP_PAY_UNI');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['SUSP_PAY_UNI'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('SUSP_LATE_BI');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['SUSP_LATE_BI'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('SUSP_VOL');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['SUSP_VOL'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('WAIT_CALL');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['WAIT_CALL'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('WAIT_MUSIC');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['WAIT_MUSIC'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('CALLER_ID');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['CALLER_ID'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('PRIVATED_ID');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['PRIVATED_ID'];?>
				</td>
			</tr>
			<tr>
				<td align=left bgcolor="#EFEFEF" colspan=4>
					&nbsp;<b><?php echo $this->mainObj->translateWord('ABREVIATED_CALL');?></b>
				</td>
				<td align=center colspan=2>
					<?php echo $res['trans']['ABREVIATED_CALL'];?>
				</td>
			</tr>
			<tr>
				<td colspan=6>
					&nbsp;
				</td>
			</tr>
			<tr>
				<td colspan=6 bgcolor="#CCCCCC">
					&nbsp;<b><?php echo $this->mainObj->translateWord('PDP_INFO_TITLE');?></b>
				</td>
			</tr>
			
			<tr>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('APN_ID');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('APN_NAME');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('EQOSID');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('EPSQOSID');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('VPAA');?></b>
				</td>
				<td align=center bgcolor="#EFEFEF">
					<b><?php echo $this->mainObj->translateWord('PDPTY');?></b>
				</td>
			</tr>
			<?php
			foreach($res['trans']['APN'] AS $apn){
				?>
				<tr>
					<td align=center>
						<?php echo $apn['APN_ID'];?>
					</td>
					<td align=center>
						<?php echo $apn['APN_NAME'];?>
					</td>
					<td align=center>
						<?php echo $apn['EQOSID'];?>
					</td>
					<td align=center>
						<?php echo $apn['EPSQOSID'];?>
					</td>
					<td align=center>
						<?php echo $apn['VPAA'];?>
					</td>
					<td align=center>
						<?php echo $apn['PDPTY'];?>
					</td>
				</tr>
				<?php
			} 
			?>
		</table>







		<?php
		}else{
//DESDE AQUI 2G/3G
		?>
	<table width="98%" border="1" align="center" cellspacing="0" bordercolor="#666666" id="id_0">
	<tr>
	<td colspan="6" bgcolor="#666666"><font size="2" color="WHITE"><strong>&nbsp;INFORMACI&Oacute;N DEL SUBSCRIPTOR</strong></font></td>
	</tr>
	<tr class="bodytextHLR">
		<td width="9%">&nbsp;<strong>HLR</strong></td>
		<td width="14%">&nbsp;<strong>MSISDN</strong></td>
		<td width="18%">&nbsp;<strong>IMSI</strong></td>
		<td width="18%">&nbsp;<strong>ESTADO</strong></td>
		<td width="24%">&nbsp;<strong>AUTENTICACI&Oacute;N</strong></td>
		<td width="17%">&nbsp;<strong>ACCESO SERV.</strong></td>
	</tr>
	<tr>
		<td class="bodytext">&nbsp;<?php echo $res['HLR']['HLRINFO']['name'];?></td>
		<td class="bodytext">&nbsp;<?php echo $res['SUSCRIBER_IDENTITY']['MSISDN']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['SUSCRIBER_IDENTITY']['IMSI']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['SUSCRIBER_IDENTITY']['STATE']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['SUSCRIBER_IDENTITY']['AUTHD']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['NAM']; ?></td>
	</tr>
	</table>
	<br>
	<table width="98%" border="1" align="center" cellspacing="0" bordercolor="#666666">
	<tr>
		<td colspan="6" bgcolor="#666666"><font size="2" color="WHITE"><strong>&nbsp;INFORMACIÓN DE LOCALIZACIÓN</strong></font></td>
	</tr>
	<tr class="bodytextHLR">
		<td width="17%">&nbsp;<strong>REGISTRO DE VOZ</strong></td>
		<td width="17%">&nbsp;<strong>MSC NUMBER</strong></td>
		<td width="17%">&nbsp;<strong>REGISTRO DE DATOS</strong></td>
		<td width="17%">&nbsp;<strong>PAIS</strong></td>
		<td width="16%">&nbsp;<strong>OPERADOR</strong></td>
		<td width="16%">&nbsp;<strong>CENTRAL</strong></td>
	</tr>
	<tr>
		<td class="bodytext">&nbsp;<?php echo $res['VLR']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['MSC']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['SGSN']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['OPER']['pais']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['OPER']['operador']; ?></td>
		<td class="bodytext">&nbsp;<?php echo $res['OPER']['central']; ?></td>
	</tr>
	</table>
	<br>
	<table width="98%" border="1" align="center" cellspacing="0" bordercolor="#666666" id="id_0000">
	<tr>
		<td colspan="2" bgcolor="#666666"><font size="2" color="WHITE"><strong>&nbsp;SERVICIOS APROVICIONADOS</strong></font></td>
	</tr>
	<tr class="bodytextHLR">
		<td width="50%">&nbsp;<strong>SERVICIO</strong></td>
		<td width="50%">&nbsp;<strong>ESTADO</strong></td>
	</tr>
	<tr>
		<td class="bodytextHLR">&nbsp;RECEPCION DE MENSAJE</td>
		<td class="bodytext">&nbsp;<?php if($res['TS211']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
		<td class="bodytextHLR">&nbsp;MENSAJERIA ORIGINADA</td>
		<td class="bodytext">&nbsp;<?php if($res['TS221']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;RESTRICCION TRAFICO ROAMING</td>
		<td class="bodytext">&nbsp;<?php if($res['OBR1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;RESTRICCION TRAFICO INTERNACIONAL</td>
		<td class="bodytext">&nbsp;<?php if($res['OBO2']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;CLIENTE CON TRAFICO</td>
		<td class="bodytext">&nbsp;<?php if($res['OFA1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;DESVIO A BUZON DE VOZ (TODOS LOS LLAMADOS)</td>
		<td class="bodytext">&nbsp;<?php if($res['CFU']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;DESVIO A BUZON DE VOZ (EN CASO DE ACUPADO)</td>
		<td class="bodytext">&nbsp;<?php if($res['CFB']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;DESVIO A BUZON DE VOZ (NO CONTESTA 30 Seg.)</td>
		<td class="bodytext">&nbsp;<?php if($res['CFNRY']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;DESVIO A BUZON DE VOZ (APAGADO O FUERA DE COBERTURA)</td>
		<td class="bodytext">&nbsp;<?php if($res['CFNRC1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;SUSPENSIÓN POR PAGO UNIDIRECCIONAL</td>
		<td class="bodytext">&nbsp;<?php if($res['OSB3']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;SUSPENSIÓN POR MOROSIDAD BIDIRECCIONAL</td>
		<td class="bodytext">&nbsp;<?php if(($res['OSB31'])AND($res['OBI1'])){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;SUSPENSIÓN POR SINIESTRO O SUSPENSIÓN VOLUNTARIA</td>
		<td class="bodytext">&nbsp;<?php if(($res['OBO1'])AND($res['TICK110'])){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;LLAMADA EN ESPERA</td>
		<td class="bodytext">&nbsp;<?php if(($res['CAW1'])AND($res['HOLD1'])){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
		<td class="bodytextHLR">&nbsp;TU MUSICA EN ESPERA</td>
		<td class="bodytext">&nbsp;<?php if($res['PRBT1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
		<td class="bodytextHLR">&nbsp;CALLER ID</td>
		<td class="bodytext">&nbsp;<?php if($res['CLIP1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
	<td class="bodytextHLR">&nbsp;ID PRIVADO</td>
		<td class="bodytext">&nbsp;<?php if($res['CLIR1']){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	<tr>
		<td class="bodytextHLR">&nbsp;MARCACION ABREVIADA 188;181</td>
		<td class="bodytext">&nbsp;<?php if(($res['STYPE1'])AND($res['STYPE14'])){ echo "ACTIVO"; }else{ echo "NO ACTIVADO"; } ?></td>
	</tr>
	</table>
	<br>
	<table width="98%" border="1" align="center" cellspacing="0" bordercolor="#666666" id="id_0000">
		<tr>
			<td colspan="5" bgcolor="#666666">
				<font size="2" color="WHITE"><strong>&nbsp;PACKET DATA PROTOCOL CONTEXT DATA</strong></font>
			</td>
		</tr>
		<tr class="bodytextHLR">
			<td width="13%">&nbsp;<strong>APNID</strong></td>
			<td width="27%">&nbsp;<strong>APN NAME</strong></td>
			<td width="20%">&nbsp;<strong>EQOSID</strong></td>
			<td width="20%">&nbsp;<strong>VPAA</strong></td>
			<td width="20%">&nbsp;<strong>PDPTY</strong></td>
		</tr>
		<?php
		foreach ($res['APNS'] as $apn){
			?>
			<tr>
				<td class="bodytext">&nbsp;<? echo $apn['APNID']; ?></td>
				<td class="bodytext">&nbsp;<? echo $apn['APNNAME']; ?></td>
				<td class="bodytext">&nbsp;<? echo $apn['EQOSID']; ?></td>
				<td class="bodytext">&nbsp;<? echo $apn['VPAA']; ?></td>
				<td class="bodytext">&nbsp;<? echo $apn['PDPTY']; ?></td>
			</tr>
			<?php
		}
		?>
	</table>
		<?php
		}
	break;
}
?>
